package com.example.saiaadmin.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.saiaadmin.entry.EbSystemDictType;
import com.example.saiaadmin.entry.EbSystemPost;
import com.example.saiaadmin.service.EbSystemDictTypeService;
import com.example.saiaadmin.utils.PageBean;
import com.example.saiaadmin.utils.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 字典类型表Controller
 *
 *  @author  Vagrant
 * @since 2025/01/13
 */
@RestController
@RequestMapping("/eb-system-dict-type")
public class EbSystemDictTypeController {
    @Autowired
    private EbSystemDictTypeService service;

    /**
     * 分页查询字典类型
     * @param page
     * @param limit
     * @param name
     * @param status
     * @return
     */
    @GetMapping("/index")
    public ResultData<PageBean<EbSystemDictType>> index(Integer page, Integer limit, String name, Integer status){
        Page<EbSystemDictType> pageInfo = new Page<>(page,limit);
        LambdaQueryWrapper<EbSystemDictType> queryWrapper =new LambdaQueryWrapper<>();
        queryWrapper.eq(null != name,EbSystemDictType::getName,name);
        queryWrapper.eq(null != status,EbSystemDictType::getStatus,status);
        service.page(pageInfo,queryWrapper);
        PageBean<EbSystemDictType> pageBean = new PageBean<>();
        pageBean.setTotal(pageInfo.getTotal());
        pageBean.setData(pageInfo.getRecords());
        pageBean.setPer_page((int) pageInfo.getSize());
        pageBean.setLast_page((int) pageInfo.getPages());
        return ResultData.success("获取成功", pageBean);
    }
}
